import { UI_Layer, UI_Listen } from '../../config/ui_def'
import { Sdk_Platform } from '../../frame/constants';
cc.Class({
    extends: cc.Component,

    properties: {
        ad_btn: cc.Node,
        ad_icon: cc.Sprite,
    },

    // LIFE-CYCLE CALLBACKS:
    // update (dt) {},

    initPage() {
        this.ad_btn.active = false
        switch (common.sdk_env) {
            case Sdk_Platform.OPPO:
                this.ad_btn.active = true
                break
        }

    },
    updatePage() {
        this.num = Math.ceil(Math.random() * 2)//20 的几率弹出
        switch (this.num) {
            case 1:
                this.ad_icon.spriteFrame = he.load.get('adicon', cc.SpriteAtlas, 'plist').getSpriteFrame(`2`)
                break;
            default:
                this.ad_icon.spriteFrame = he.load.get('adicon', cc.SpriteAtlas, 'plist').getSpriteFrame(`1`)
                break;
        }
       
    },
    adServer(){
        switch (this.num) {
            case 1:
                qg.navigateToMiniGame({
                    pkgName: 'com.lxkj.gtflzdcf.nearme.gamecenter',
                    success: function (res) {
                        console.log(JSON.stringify(res))
                    },
                    fail: function (res) {
                        console.log(JSON.stringify(res))
                    }
                })
                break;
            default:
                qg.navigateToMiniGame({
                    pkgName: 'com.zqzs.nearme.gamecenter',
                    success: function (res) {
                        console.log(JSON.stringify(res))
                    },
                    fail: function (res) {
                        console.log(JSON.stringify(res))
                    }
                })
                break;
        }
    },
    closeUI() {

    },


    passListBtnServer() {
        he.voice.playEffect("button", "voice")
        gg.uiManager.addPage(UI_Layer.Cover, {
            name: 'rankMainPage',
            cover: true,
            // close: true
        })

        gg.eventManager.emit('main', { type: UI_Listen.MAIN_CLOSEPAGE, pageName: 'bottomSec' })
    },


    testBtnServer() {
        he.voice.playEffect("button", "voice")
        gg.uiManager.addPage(UI_Layer.Cover, {
            name: 'storePage',
            cover: true,
            // close: true
        })
        gg.eventManager.emit('main', { type: UI_Listen.MAIN_CLOSEPAGE, pageName: 'bottomSec' })
        gg.uiManager.addPage(UI_Layer.Cover, {
            name: 'topBar',
            // close: true
        })
    },
});
